﻿// Sequin.Sequences.Mining.Projection
//
// (c) 2011 Arthur Pitman
//
// Part of the Sequin Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License (Version 2.1) as published by the Free Software Foundation.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License (Version 2.1) along with this library; if not, write to the 
// Free Software Foundation, Inc., 
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
// or see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sequin.Sequences.Mining
{
	/// <summary>
	/// Represents a projection, i.e. a series of projected sequences
	/// </summary>
	public class Projection
	{
		/// <summary>
		/// The id of the projection
		/// </summary>
		public long Id { get; protected set; }

		/// <summary>
		/// The depth of the projection
		/// </summary>
		public int Depth { get; protected set; }

		/// <summary>
		/// The parent of the projection
		/// </summary>
		public Projection Parent { get; protected set; }

		/// <summary>
		/// The projecting sequence
		/// </summary>
		public Sequence ProjectingSequence { get; protected set; }

		/// <summary>
		/// The set of projected sequences, i.e. the projected database
		/// </summary>
		public List<ProjectedSequence> ProjectedDb { get; protected set; }   

		/// <summary>
		/// Initializes a new <see cref="Projection"/> instance with the given database
		/// This constructor is used to create the initial projection
		/// </summary>
		/// <param name="id">the id of the projection</param>
		/// <param name="projectedDb">initial projected database</param>
		public Projection(int id, List<ProjectedSequence> projectedDb)
		{
			Id = id;
			Depth = 0;
			Parent = null;			
			ProjectingSequence = new Sequence();
			ProjectedDb = projectedDb;
		}

		/// <summary>
		/// Initializes a new <see cref="Projection"/> instance
		/// </summary>
		/// <param name="id">the id of the projection</param>
		/// <param name="parent">The parent <see cref="Projection"/></param>
		/// <param name="projectingSequence">the projecting <see cref="Sequence"/></param>		
		/// <param name="projectedDb">the projected database</param>
		public Projection(int id, Projection parent, Sequence projectingSequence, List<ProjectedSequence> projectedDb)
		{
			Id = id;
			Parent = parent;
			Depth = parent.Depth + 1;		
			ProjectingSequence = projectingSequence;
			ProjectedDb = projectedDb;
		}          
	}
}
